package com.bt.lms.ui.page.teaching.plan;

import com.bt.lms.ui.action.teaching.plan.LSetTeachingPlanCancelBtnAction;
import com.bt.lms.ui.action.teaching.plan.LSetTeachingPlanSaveBtnAction;
import com.bt.lms.ui.page.sys.style.BtnStyle;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;

/**
 * 教学计划
 * 新增教学计划基本信息
 */
public class PageSetTeachingPlanBasicInfo extends VBox {

    /**
     * 标题的宽
     */
    public Integer width = 200;

    /**
     * 宽
     */
    public Integer preWidth = 1040;


    /**
     * 设置教学计划基本信息
     */
    public PageSetTeachingPlanBasicInfo(){


        //初始化所在位置
        initLocation();

        //初始化小标题
        initSLab();


        //新增教学计划内容
        initBasicInfo();

        this.setPrefWidth(preWidth);

        //按钮
        HBox hBox = new HBox();
        hBox.setSpacing(10);
        hBox.setAlignment(Pos.CENTER);
        Button saveBtn = new Button("保存并返回");
        BtnStyle.saveBtn(saveBtn);
        saveBtn.setCursor(Cursor.HAND);
        LSetTeachingPlanSaveBtnAction setTeachingPlanSaveBtnAction = new LSetTeachingPlanSaveBtnAction();
        setTeachingPlanSaveBtnAction.setPlan(this);
        saveBtn.setOnAction(setTeachingPlanSaveBtnAction);
        Button cancelBtn = new Button("取消");
        BtnStyle.cancelBtn(cancelBtn);
        cancelBtn.setCursor(Cursor.HAND);
        LSetTeachingPlanCancelBtnAction setTeachingPlanCancelBtnAction = new LSetTeachingPlanCancelBtnAction(this);
        cancelBtn.setOnAction(setTeachingPlanCancelBtnAction);
        hBox.getChildren().addAll(saveBtn,cancelBtn);
        this.getChildren().add(hBox);


    }

    /**
     * 初始化所在位置
     */
    public void initLocation(){

        HBox hBox = new HBox();
        Insets insets = new Insets(10);
        hBox.setPadding(insets);
        Label label = new Label("当前位置：🏠>教学管理>教学计划>新增关联课程");
        Font font = Font.font("仿宋", FontWeight.THIN, FontPosture.REGULAR,18);
        label.setFont(font);
        hBox.getChildren().add(label);
        this.getChildren().add(hBox);

    }

    /**
     * 初始化小标题
     */
    public void initSLab(){

        HBox hBox = new HBox();
        Insets insets = new Insets(10);
        hBox.setPadding(insets);
        Label label = new Label("设置教学计划基本信息");
        Font font = Font.font("仿宋", FontWeight.THIN, FontPosture.REGULAR,15);
        label.setFont(font);
        hBox.getChildren().add(label);
        this.getChildren().add(hBox);
    }

    /**
     * 新增教学计划内容
     */
    public void initBasicInfo(){

        //基本信息主盒子
        VBox vBox = new VBox();
        Insets insets = new Insets(10);
        vBox.setPadding(insets);
        vBox.setSpacing(10);
        //计划编号
        HBox codeHBox = new HBox();
        codeHBox.setSpacing(10);
        Label codeLabel = new Label("计划编号*");
        codeLabel.setPrefWidth(width);
        TextField codeTF = new TextField();
        codeTF.setPromptText("你好，请输入计划编号");
        codeTF.setId("codeTF");
        ObservableList<Node> codeChildren = codeHBox.getChildren();
        codeChildren.addAll(codeLabel,codeTF);
        //教学计划名称
        HBox nameHBox = new HBox();
        nameHBox.setSpacing(10);
        Label nameLab = new Label("教学计划名称*");
        nameLab.setPrefWidth(width);
        TextField nameTF = new TextField();
        nameTF.setId("nameTF");
        ObservableList<Node> nameHBoxChildren = nameHBox.getChildren();
        nameHBoxChildren.addAll(nameLab,nameTF);
        //所属的学习中心
        HBox belongToCollegeHBox = new HBox();
        belongToCollegeHBox.setSpacing(10);
        Label belongToCollegeLabel = new Label("所属的学习中心*");
        belongToCollegeLabel.setPrefWidth(width);
        ComboBox<String> belongToCollegeComboBox = new ComboBox<>();
        belongToCollegeComboBox.setCursor(Cursor.HAND);
        belongToCollegeComboBox.setId("belToCollegeCB");
        belongToCollegeComboBox.getSelectionModel().select("北京大学");
        belongToCollegeComboBox.getItems().add("北京师范大学");
        belongToCollegeComboBox.getItems().add("北京大学");
        ObservableList<Node> belongToCollegeHBoxChildren = belongToCollegeHBox.getChildren();
        belongToCollegeHBoxChildren.addAll(belongToCollegeLabel,belongToCollegeComboBox);
        //所属专业
        HBox belongToMajorHBox = new HBox();
        belongToMajorHBox.setSpacing(10);
        Label belongToMajorLabel = new Label("所属专业");
        belongToMajorLabel.setPrefWidth(width);
        ComboBox<String> belongToMajorComboBox = new ComboBox<>();
        belongToMajorComboBox.setCursor(Cursor.HAND);
        belongToMajorComboBox.setId("belongToMajor");
        belongToMajorComboBox.getSelectionModel().select("java");
        belongToMajorComboBox.getItems().add("java");
        belongToMajorComboBox.getItems().add("c++");
        belongToMajorComboBox.getItems().add("c");
        ObservableList<Node> belongToMajorHBoxChildren = belongToMajorHBox.getChildren();
        belongToMajorHBoxChildren.addAll(belongToMajorLabel,belongToMajorComboBox);
        //适合层次
        HBox applyLevelHBox = new HBox();
        applyLevelHBox.setSpacing(10);
        Label applyLevelLabel = new Label("适合层次*");
        applyLevelLabel.setPrefWidth(width);
        ComboBox<String> applyLevelComboBox = new ComboBox<>();
        applyLevelComboBox.setCursor(Cursor.HAND);
        applyLevelComboBox.setId("applyCB");
        applyLevelComboBox.getSelectionModel().select("高中");
        applyLevelComboBox.getItems().add("高中");
        applyLevelComboBox.getItems().add("大专");
        applyLevelComboBox.getItems().add("本科");
        ObservableList<Node> applyLevelHBoxChildren = applyLevelHBox.getChildren();
        applyLevelHBoxChildren.addAll(applyLevelLabel,applyLevelComboBox);
        //学制
        HBox lengthOfSchoolingHBox = new HBox();
        lengthOfSchoolingHBox.setSpacing(10);
        Label lengthOfSchoolingLabel = new Label("学制*");
        lengthOfSchoolingLabel.setPrefWidth(width);
        TextField lengthOfSchoolingTF = new TextField();
        lengthOfSchoolingTF.setId("lengthOfSchoolingTF");
        ComboBox<String> lengthOfSchoolingComboBox = new ComboBox<>();
        lengthOfSchoolingComboBox.setCursor(Cursor.HAND);
        lengthOfSchoolingComboBox.setId("lengthOfSchoolingCB");
        lengthOfSchoolingComboBox.getSelectionModel().select("年");
        lengthOfSchoolingComboBox.getItems().add("年");
        lengthOfSchoolingComboBox.getItems().add("月");
        lengthOfSchoolingComboBox.getItems().add("学时");
        ObservableList<Node> lengthOfSchoolingHBoxChildren = lengthOfSchoolingHBox.getChildren();
        lengthOfSchoolingHBoxChildren.addAll(lengthOfSchoolingLabel,lengthOfSchoolingTF,lengthOfSchoolingComboBox);
        //可重修次数
        HBox numberOfRepairableTimesHBox = new HBox();
        numberOfRepairableTimesHBox.setSpacing(10);
        Label numberOfRepairableTimesLabel = new Label("可重修次数");
        numberOfRepairableTimesLabel.setPrefWidth(width);
        TextField numberOfRepairableTimesTF = new TextField();
        numberOfRepairableTimesTF.setId("numberOfRepairableTimesTF");
        ObservableList<Node> periodOfSchoolingHBoxChildren = numberOfRepairableTimesHBox.getChildren();
        periodOfSchoolingHBoxChildren.addAll(numberOfRepairableTimesLabel,numberOfRepairableTimesTF);
        //小盒子放大盒子里
        ObservableList<Node> children = vBox.getChildren();
        children.addAll(codeHBox,nameHBox,belongToCollegeHBox,belongToMajorHBox,
                applyLevelHBox,lengthOfSchoolingHBox,numberOfRepairableTimesHBox);

        //放到主盒子里
        this.getChildren().add(vBox);

    }

}
